package com.echo.code.thread.mode.nio2;

import com.echo.code.thread.mode.listener.EventBus;
import java.io.IOException;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
 * TestCase Created by baiyap on 2018/9/24.
 */
public class TestCase {

  public static void main(String[] args) throws Exception {
    Thread thread = new Thread(() -> {
      try {
        EventBus eventBus = new EventBus(Executors.newSingleThreadExecutor(), null);
        eventBus.register(new FileChangeListener());
        DirectoryTargetMonitor monitor = new DirectoryTargetMonitor(eventBus, "/Users/ada");
        monitor.startMonitor("default");
      } catch (IOException e) {
        e.printStackTrace();
      }
    });
    thread.start();
    TimeUnit.SECONDS.sleep(30);
    thread.interrupt();
  }
}
